<?php

namespace app\airobot;

use app\airobot\model\UserModel;
use app\airobot\model\UserRelation;

class FundConst
{
    public static function getUserIdSql($sqlField, $managerId)
    {
        if ($managerId == "10000") {
            return "";
        }

        $pids = self::$PidMap[$managerId];

        $userRelationModel = new UserRelation();
        $childUserList = $userRelationModel->queryList([], ["field" => "root_uid", "data" => $pids], [], [], [], "", $field = "*", $order = "id asc");
        $allChildUserArr = [];
        foreach ($childUserList as $value) {
            $userIdArr = explode(",", $value['user_id']);
            $allChildUserArr = array_merge($allChildUserArr, $userIdArr);
        }

        return " and " . $sqlField . " in (" . implode(",", $allChildUserArr) . ")";
    }

    public static function getUserIds($managerId)
    {
        $pids = self::$PidMap[$managerId];

        $userRelationModel = new UserRelation();
        $childUserList = $userRelationModel->queryList([], ["field" => "root_uid", "data" => $pids], [], [], [], "", $field = "*", $order = "id asc");
        $allChildUserArr = [];
        foreach ($childUserList as $value) {
            $userIdArr = explode(",", $value['user_id']);
            $allChildUserArr = array_merge($allChildUserArr, $userIdArr);
        }
        return implode(",", $allChildUserArr);
    }

    public static $PidMap = [
        // all
        "10000" => [
        ],
        // 何总:  qphymwgxt
        "10003" => [
            "35",
            "36",
            "45",
            "49",
            "50",
            "55",
            "43",
        ],
        // 2哥:  administrator
        "10004" => [
        ],
        // QP:  administrator
        "10005" => [
            "49",
            "43",
        ],
    ];

    public static $RobotType = [
        "0" => "",
        "" => "-全部-",
        "1" => "现货-进阶动量马丁",
        "2" => "U本位-进阶动量马丁",
        "3" => "币本位-进阶动量马丁",
        "4" => "现货-多币均衡混合模型",
        "5" => "现货-AI趋势预测模型",
        "6" => "U本位-AI趋势预测模型",
        "7" => "币本位-AI趋势预测模型",
        "8" => "现货-定投机器人",
        "9" => "现货-梯度下降追踪买入",
        "10" => "现货-梯度上升追踪卖出",
        "11" => "现货-进阶动态网络",
    ];

    public static $CoinType = [
        "0" => "",
        "1" => "现货",
        "2" => "U本位",
        "3" => "币本位",
    ];
}
